import Vue from 'vue'
import VueRouter from 'vue-router'
import Register from "@/views/Register.vue";
import HomeView from "@/views/HomeView.vue";
import Login from "@/views/Login.vue";
import Chat from "@/components/Chat.vue";
import OrderForm from "@/components/OrderForm.vue";
import Find from "@/views/Find.vue";
import Form2 from "@/components/Form2.vue";
import NotFound from "@/views/NotFound.vue";

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView
  },{
    path: '/find',
    name: 'find',
    component: Find
  }, {
    path: '/login',
    name: 'login',
    component: Login
  }, {
    path: '/register',
    name: 'register',
    component: Register
  }, {
    path: '/order',
    name: 'order',
    component: OrderForm
  }, {
    path: '/chat',
    name: 'chat',
    component: Chat
  }, {
    path: '/form2',
    name: 'form2',
    component: Form2
  },{
    path: '/accOrder',
    name: 'accOrder',
    component: NotFound
  }, {
    // URL无法匹配，重定向到home
    path: '*',
    redirect:'/'
  },


  // {
  //   path: '/about',
  //   name: 'about',
  //   // route level code-splitting
  //   // this generates a separate chunk (about.[hash].js) for this route
  //   // which is lazy-loaded when the route is visited.
  //   component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  // }
]

const router = new VueRouter({
  mode: 'history', //路由模式，一般用hash，但一开始不懂就用了history
  base: process.env.BASE_URL,
  routes
})

export default router
